import { fetchCarRegDetailAPI, fetchCarRegisterListAPI } from '@/constants/vehicle/carRegister'

const actions = {
  /*
  *分页查询回车登记列表的action
  *  */
  async fetchCarRegisterListAction(context, pageParams) {
    const { data } = await fetchCarRegisterListAPI(pageParams)
    context.commit('setCarRegisterListMutation', data)
  },
  /*
  *
  * 获取回车登记详情得到action
  *  */
  async fetchCarRegDetailAction(context, id) {
    const { data } = await fetchCarRegDetailAPI(id)
    return data
  }
}
const mutations = {
  /*
  * 设置回车登记列表的mutation
  *  */
  setCarRegisterListMutation(state, { counts, items }) {
    state.counts = Number(counts)
    state.carRegisterList = items
  }
}
const state = () => {
  return {
    counts: 0,
    carRegisterList: []
  }
}

export default {
  actions,
  mutations,
  state,
  namespaced: true
}
